home *** CD-ROM | disk | FTP | other *** search
- #ifndef XPKMASTER_CHECKSUM_C
- #define XPKMASTER_CHECKSUM_C
-
- /* Routinesheader
-
- Name: checksum.c
- Main: xpkmaster
- Versionstring: $VER: checksum.c 1.2 (31.01.97)
- Author: SDI
- Distribution: PD
- Description: Simple checksum routines
-
- 1.0 05.10.96 : first real version
- 1.1 30.01.97 : added new option to cchecksum, became necessary
- 1.2 31.01.97 : removed option
- */
-
- #include <exec/types.h>
-
- UBYTE hchecksum(STRPTR ptr, ULONG count)
- {
- register UBYTE sum = 0;
-
- while(count-- > 0)
- sum ^= *ptr++;
-
- return sum;
- }
-
- UWORD cchecksum(ULONG *ptr, ULONG count)
- {
- register ULONG sum = 0;
-
- while(count-- > 0)
- sum ^= *ptr++;
-
- return (UWORD) (sum ^ (sum >> 16));
- }
-
- #endif /* XPKMASTER_CHECKSUM_C */
-